<%-- 
  - Author: Mohtisham.Salahria
  - Date: 19-May-2011
  - Copyright Notice: TRAKHEES
  - Description: form.jsp
 --%>

<%@ include file="/WEB-INF/view/include.jsp"%>
<%@ page import="ae.pcfc.etks.online.web.*"%>
<script>
  $().ready(function(){
  
	//$("input:submit, input:reset, input:button, input:file").button();
	  
    $("#UserServiceValue").validate({
		onfocusout : false,
		onkeyup : false,
		//onclick: false,			
		rules : {			
		},
		showErrors : function(errorMap, errorList) {

			var errors = '<ul>';
			var label;
			if (errorList.length) {
				$.each(errorMap, function(name, value) {
					label = $("label[for='" + name + "']").html();
					label = value + '[' + label + ']';
					errors = errors + '<li>' + label + '</li>';

				});
				errors = errors + '</ul>';
				jAlert('error', errors, '<spring:message code="label.errormessage" />');
			}
		}

	});
    
    
  });
 </script>


<div id="container" dir='<spring:message code="page.dir"/>'  align='<spring:message code="page.align"/>' class="t_fin-black-txt">


<form:form name="UserServiceValue" id="UserServiceValue"  method="POST" 
		modelAttribute="<%=ConstantsAdmin.USER_SERVICE_VALUE_REQUEST_MODEL_KEY %>">
		
		<spring:hasBindErrors
			name="<%=ConstantsAdmin.USER_SERVICE_VALUE_REQUEST_MODEL_KEY %>">
			<script type="text/javascript">
				$(document)
						.ready(
								function() {
									jAlert(
											'error',
											'<li><form:errors path="*" delimiter="<li>"/>',
											'<spring:message code="label.errormessage" />');
								});
			</script>
		</spring:hasBindErrors>
		
	 <%
			 	if(request.getAttribute(ConstantsAdmin.SUCCESS_PARAM) != null) {
			 %>
		   	<spring:message code="label.success.registerservice"/>
		   <% } %>
	
	<div class="ui-widget_c ui-corner-all">
		<div class="ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix"><spring:message code="label.user.services" /></div>
       	<div class="ui-widget_content_c ">
		
		 <c:forEach items="${userServiceValue}" var="serviceVO" varStatus="status">   
		 	
		 	<fieldset>
					<legend>
					<c:choose>	
						<c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
						  	<!--<spring:message code="label.servicename.arb" />
					     	--><c:out value="${serviceVO.strServiceNameArb}"/>
					     </c:when>
					     <c:otherwise>					    	
					      	<c:out value="${serviceVO.strServiceNameEng}"/> 	
					     </c:otherwise>
					 </c:choose>    
					</legend>
			</fieldset>					
					<input value="${serviceVO.strServiceID}" id="${serviceVO.strServiceID}" name="${serviceVO.strServiceID}" type="hidden"/>
					 <c:forEach items="${serviceVO.arrServiceAttributes}" var="serviceAttribute" varStatus="status">
		 	 		 <c:if test="${serviceAttribute.serviceAttrStatus == 'A'}">
		 	 		 <!-- JSTL variable is used to avoid blank spaces which are produced by the code -->	
		 	 			<c:choose>
			 	 			<c:when test='${requestScope.requestContextAttribute.locale.language == "ar"}'>
								  <c:set var="attrLabel" value="${serviceAttribute.strServiceAttributeNameARB}" scope="page" />
								 <c:out value="${serviceAttribute.strServiceAttributeNameARB}"/>
							</c:when>
						     <c:otherwise>
						     	  <c:set var="attrLabel" value="${serviceAttribute.strServiceAttributeNameENG}" scope="page" />	
						     </c:otherwise>
						</c:choose>
		 	 		<!-- JSTL variable -->	
		 	 		
		 	 			<div class="t_form-left">		 	 				
		 	 			<label for=<c:out value="${serviceAttribute.iAttrId}"/>>
		 	 				<c:choose>
		 	 					<c:when test="${serviceAttribute.strNecessisty == 'M'}">
		 	 						<span class="t_star">*</span>		 	 					
		 	 					</c:when>		 	 					
		 	 				</c:choose>
		 	 				<c:out value="${attrLabel}" />
						</label><input type="text" name="${serviceAttribute.iAttrId}" id="${serviceAttribute.iAttrId}" <c:if test="${serviceAttribute.strNecessisty == 'M'}"><c:out value='class=required'/></c:if> />  			 	
					 </div>
					 <div style="clear:both"></div>
					 </c:if>
					 </c:forEach>   
	
		</c:forEach>	
		<div id="fm-submit" class="fm-req">
				<input type="submit" name="save" value="<spring:message code="label.button.save" />" class="t_btns save"/>
				<input type="reset" name="reset" value="<spring:message code="label.button.reset" />" class="t_btns reset"/>
		</div>	
		</div>
	</div>	
	
	
	</form:form>
</div>
